﻿<%@ Page Title="" Language="C#" MasterPageFile="/Common/Master.master" %>

<script runat="server">

</script>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentForm" runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentHtml" runat="Server">
    <div class="easyui-layout tableEdit" data-options="fit:true,border:false">
        <div data-options="region:'center',border:false" id="validation" class="validationEngineContainer">
            <div class="z_wrap">
                <ul class="info">
                    <li>
                        <em class='l_name'>自增主键：</em>
                        <div class='r_con1'><span id='ID' name='ID'>自动</span></div>
                    </li>
                    <li>
                        <em class='l_name'>项目名称：</em>
                        <div class='r_con1'>
                            <input id='Name' name='Name' type='text' class='validate[required]' data-prompt-position='bottomRight' /></div>
                    </li>
                    <li>
                        <em class='l_name'>项目负责人：</em>
                        <div class='r_con1'>
                            <input id='dd_user_id' name='dd_user_id' type='text' class='validate[required]' data-prompt-position='bottomRight' /></div>
                    </li>
                    <li>
                        <em class='l_name'>详细地址：</em>
                        <div class='r_con1'>
                            <input id='address' name='address' type='text' class='validate[required]' data-prompt-position='bottomRight' /></div>
                    </li>
                    <li>
                        <em class='l_name'>备注：</em>
                        <div class='r_con1'>
                            <input id='remark' name='remark' type='text' class='validate[required]' data-prompt-position='bottomRight' /></div>
                    </li>
                    <li>
                        <em class='l_name'>位置经度：</em>
                        <div class='r_con1'>
                            <input id='longitude' name='longitude' type='text' class='validate[required]' data-prompt-position='bottomRight' /></div>
                    </li>
                    <li>
                        <em class='l_name'>位置维度：</em>
                        <div class='r_con1'>
                            <input id='latitude' name='latitude' type='text' class='validate[required]' data-prompt-position='bottomRight' /></div>
                    </li>
                    <li>
                        <em class='l_name'>项目状态：</em>
                        <div class='r_con1'>
                            <input id='status' name='status' type='text' class='validate[required]' data-prompt-position='bottomRight' /></div>
                    </li>
                    <li>
                        <em class='l_name'>城市：</em>
                        <div class='r_con1'>
                            <input id='city' name='city' type='text' class='validate[required]' data-prompt-position='bottomRight' /></div>
                    </li>
                    <li>
                        <em class='l_name'>是否删除：</em>
                        <div id='IsDelete' class='r_con1'>自动</div>
                    </li>
                    <li>
                        <em class='l_name'>创建人：</em>
                        <div id='AddUserID' class='r_con1'>自动</div>
                    </li>
                    <li>
                        <em class='l_name'>上次修改人：</em>
                        <div id='LastUserId' class='r_con1'>自动</div>
                    </li>
                    <li>
                        <em class='l_name'>创建时间：</em>
                        <div id='AddTime' class='r_con1'>自动</div>
                    </li>
                    <li>
                        <em class='l_name'>上次修改时间：</em>
                        <div id='LastTime' class='r_con1'>自动</div>
                    </li>
                </ul>
            </div>
        </div>
        <div data-options="region:'south'" style="height: 35px; border-bottom: 0px; border-left: 0px; border-right: 0px;" class="edit_bottom">
            <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-save'" id="buttonOk">确 定</a>
            <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="$.layerClose(false);">取 消</a>
        </div>
    </div>

    <script type="text/javascript">
        $(function () {
            jQuery('#validation').validationEngine();

            $("#buttonOk").click(function () {
                InsertOrUpdate();
            });
            if ($.getUrlParamer("guid") != "") {
                DataBind();
            }
        });

        function DataBind() {
            $.InvokeAjax({
                url: "Api/V1/dd_project/Getproject",
                data: { ID: $.getUrlParamer("guid") },
                callBack: function (data) {
                    var obj = $.StrToJson(data).Results;

                    $.SetValue("ID", obj.ID);
                    $.SetValue("Name", obj.Name);
                    $.SetValue("dd_user_id", obj.dd_user_id);
                    $.SetValue("address", obj.address);
                    $.SetValue("remark", obj.remark);
                    $.SetValue("longitude", obj.longitude);
                    $.SetValue("latitude", obj.latitude);
                    $.SetValue("status", obj.status);
                    $.SetValue("city", obj.city);
                    $.SetValue("IsDelete", obj.IsDelete_Name);
                    $.SetValue("AddUserID", obj.AddUserID_Name);
                    $.SetValue("LastUserId", obj.LastUserId_Name);
                    $.SetValue("AddTime", $.DateFormat(obj.AddTime, 'yyyy-MM-dd HH:mm:ss'));
                    $.SetValue("LastTime", $.DateFormat(obj.LastTime, 'yyyy-MM-dd HH:mm:ss'));

                }
            });
        }

        function InsertOrUpdate() {
            if (!$('#validation').validationEngine('validate')) { return false; }
            var url = $.getUrlParamer("guid") != "" ? "Api/V1/dd_project/Updateproject" : "Api/V1/dd_project/Addproject";

            var obj = { ID: $.getUrlParamer("guid") };
            obj.Name = $.GetValue("Name");
            obj.dd_user_id = $.GetValue("dd_user_id");
            obj.address = $.GetValue("address");
            obj.remark = $.GetValue("remark");
            obj.longitude = $.GetValue("longitude");
            obj.latitude = $.GetValue("latitude");
            obj.status = $.GetValue("status");
            obj.city = $.GetValue("city");


            $.InvokeAjax({
                url: url,
                data: obj,
                callBack: function (data) {
                    $.layerClose(true);
                }
            });
        }
    </script>
</asp:Content>
